<template>
	<div>
		<van-nav-bar title="粉丝"></van-nav-bar>
		<div style="overflow: scroll;height: calc(100vh - 46px);">
			<van-pull-refresh v-model="flashing" @refresh="flashOrder">
				<van-list v-model:loading="loading" :finished="noMore" finished-text="没有更多了"
					@load="pushOrder">
					<van-cell v-for="(user,key) in dataList" :key="key">
						<van-row style="padding: 1vh;">
							<div style="margin-right: 3vw;">
								<van-image width="10vw" height="10vw" fit="cover" :src="urlIp+'/'+user.headImgSrc" round />
							</div>
							<strong style="color: black;">
								{{user.userName}}
							</strong>
						</van-row>
					</van-cell>
				</van-list>
			</van-pull-refresh>
		</div>
	</div>
</template>

<script>
	import {
		showNotify
	} from 'vant';
	import url from '@/assets/url.json';
	
	export default {
		
		props:{
			uid: String
		},
		
		
		data() {
			return {
				noMore: false,
				flashing: false,
				loading: false,
				dataList: [],
				page: 0,
				limit: 5,
				orderOffers: '',
				urlIp: url.ip,
			}
		},
		
		methods:{
			flashOrder() {
				this.page = 0;
				
				this.dataList = [];
				this.pushOrder();
			},
				
			load() {
				
				this.pushOrder();
			},
				
				
			pushOrder() {
				this.page += 1;
				this.$axios({
					url: url.ip + '/api-user' + '/home/fans',
					method: 'GET',
					params: {
						// page: this.page,
						// limit: this.limit,
						id: this.uid
					},
					headers: {
						token: this.$cookies.get('token'),
					}
				}).then((res) => {
					console.log(res);
					if (res.data.code !== 0) {
						this.noMore = true;
						showNotify({
							type: 'danger',
							message: res.data.message
						});
					} else {
						let list = res.data.data.fansList;
						if (list.length <= 0) {
							this.noMore = true;
						} else {
							for (let key in list) {
								this.dataList.push(list[key]);
							}
							this.noMore = false;
						}
					}
					this.loading = false;
					this.flashing = false;
					this.noMore = true; // !!分页后可以删掉
				}).catch(() => {
					this.loading = false;
					this.flashing = false;
					this.noMore = true;
					showNotify({
						type: 'danger',
						message: "网络错误或未登录"
					});
				})
			}
		}
	}
</script>

<style>
</style>